<template>
	<sw-common-frame :loading="loading">
		<template slot="button">
			<el-button size="small" type="primary" icon="el-icon-plus" @click="handleOpenDialog()">新增</el-button>
			<el-divider direction="vertical"></el-divider>
			<el-radio-group size="small" v-model="activeName">
				<el-radio-button label="1">黑名单</el-radio-button>
				<el-radio-button label="2">白名单</el-radio-button>
			</el-radio-group>
		</template>
		<template slot="query">
			<el-form size="small" :inline="true">
				<el-form-item>
					<el-input placeholder="请输入名称" v-model="queryData.name" clearable style="width: 150px"></el-input>
				</el-form-item>
				<el-form-item>
					<sw-ip-input placeholder="请输入IP地址" v-model="queryData.ipAddr" clearable style="width: 150px"></sw-ip-input>
				</el-form-item>
				<el-form-item>
					<el-button type="primary" icon="el-icon-search" @click="queryTableData()">搜索</el-button>
				</el-form-item>
			</el-form>
		</template>
		<template slot="table">
			<el-table size="medium" height="100%" :data="tableData" stripe>
				<el-table-column prop="name" label="名称" min-width="180"></el-table-column>
				<el-table-column prop="ipAddr" label="IP地址" min-width="180"></el-table-column>
				<el-table-column prop="createName" label="创建人" min-width="136"></el-table-column>
				<el-table-column prop="createTime" label="创建时间" min-width="160"></el-table-column>
				<el-table-column label="操作" width="100">
					<template slot-scope="{ row }">
						<el-button size="medium" type="text" @click="handleOpenDialog(row.id)">编辑</el-button>
						<el-button size="medium" type="text" @click="handleDeleteData(row)">删除</el-button>
					</template>
				</el-table-column>
			</el-table>
		</template>
		<template slot="page">
			<sw-pagination :total="dataCount" :page.sync="queryData.page" :limit.sync="queryData.limit" @change="queryTableData()"></sw-pagination>
		</template>
		<form-dialog v-model="formDialog" :type="activeName" :data-id="dataId" @refresh="queryTableData()"></form-dialog>
	</sw-common-frame>
</template>

<script>
import formDialog from './form';
import listMixins from '@/mixins/listMixins';
import { getBlackPageList, deleteBlack } from '@/api/system/tbSysBlack';
export default {
	mixins: [listMixins],
	components: { formDialog },
	data() {
		return {
			pageName: '名单',
			activeName: '1'
		};
	},
	computed: {
		listFunction() {
			return eval(getBlackPageList);
		},
		deleteFunction() {
			return eval(deleteBlack);
		},
		requestParams() {
			return { ...this.queryData, type: this.activeName };
		}
	},
	watch: {
		activeName: {
			handler() {
				this.queryTableData();
			},
			immediate: true
		}
	},
	methods: {}
};
</script>

<style lang="scss" scoped></style>
